package com.neu.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.neu.dao.Tb_empDao;
import com.neu.entity.Tb_emp;
import com.neu.util.JDBCUtil;

public class Tb_empDaoImpl implements Tb_empDao {

	@Override
	public List<Tb_emp> select() throws SQLException {
		Connection conn = null;
		boolean flag = false;
		try {
			conn = JDBCUtil.getConn();
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String sql = "select * from tb_emp";
		PreparedStatement ps = conn.prepareStatement(sql);
		List<Tb_emp> list = new ArrayList<>();
		ResultSet rs = ps.executeQuery();
		while(rs.next()) {
			list.add(new Tb_emp(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getInt(4), rs.getString(5), rs.getDouble(6), rs.getDouble(7), rs.getInt(8)));
		}
		return list;
	}

}
